/**
 * 
 */
package com.ku6.user;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;

import org.hibernate.validator.Email;
import org.hibernate.validator.Length;
import org.jboss.seam.annotations.Name;

import com.ku6.user.Role;
import com.ku6.common.base.EntityBase;

/**
 * @author daniel 2009-1-12
 */
@Entity
@Name("user")
public class User extends EntityBase implements Serializable {

	private static final long serialVersionUID = 3842615476025326841L;

	private String nickName;

	@Length(min = 4, message = "长度少于4个字符.")
	private String password;

	@Email(message = "Email格式不正确.")
	private String email;

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	@JoinTable(name = "Users_Roles", joinColumns = { @JoinColumn(name = "User_Id", referencedColumnName = "id") }, inverseJoinColumns = { @JoinColumn(name = "Role_Id", referencedColumnName = "id") })
	private List<Role> roles = new ArrayList<Role>();// 其所有的角色

	public String getNickName() {
		return nickName;
	}

	public void setNickName(String nickName) {
		this.nickName = nickName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public List<Role> getRoles() {
		return roles;
	}

	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}
}
